<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/elec/elecGun.js"></script>
    <link href="${ctx}/statics/css/notice.css" rel="stylesheet">
    <link href="${ctx}/statics/css/newEdition.css" rel="stylesheet">

</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return'<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>首页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>通知详情</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
<%--                <div class="ibox-title">--%>
<%--                    <div class="columns pull-left">--%>
<%--                        <h5 class="font-bold">通知详情</h5>--%>
<%--                    </div>--%>
<%--                    <div class="ibox-tools">--%>
<%--                        <a class="close-link">--%>
<%--                            <i class="fa fa-times"></i>--%>
<%--                        </a>--%>
<%--                    </div>--%>
<%--                </div>--%>

                <div class="ibox-content">
                    <div class="row">
                        <div class="title col-md-12">
                            ${tenantReceive.title}
                        </div>
                    </div>

                    <div class="row">
                        <div class="second_row">
                            <span class="time col-md-2"></span>
<%--                            <button readonly="true" class="status col-md-3"></button>--%>
                                <c:choose>
                                    <c:when test='${tenantReceive.status == 1}'>
                                        <button readonly="true" class="status col-md-3">已读</button>
                                    </c:when>
                                    <c:otherwise>
                                        <button readonly="true" class="status col-md-3">未读</button>
                                    </c:otherwise>
                                </c:choose>


                            <img class="pic ">
                        </div>
                    </div>
                    <div class="row">
                        <div class="content col-md-12">
                            ${tenantReceive.content}
                        </div>
                    </div>
                    <div class="row">
                        <div class="enclosure col-md-2">附件</div>
                    </div>
                    <div class="row file1">
                        <div class="file1"></div>
                    </div>
                    <div class="row">
                        <div class="file2 col-md-2"></div>
                    </div>
                    <div class="row">
                        <div class="file3 col-md-2"></div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>




<script type="text/javascript">
    // addElecGun.init();
    // var ocssRules1 = document.styleSheets[19].rules||document.styleSheets[19].cssRules;

    $(function(){

        // alert($(".pic_num").siblings("img").attr("src"));
        // $(".pic_num").html()
        // return
        setTimeout(function(){
            var ocssRules1 = document.styleSheets[19].cssRules;
            var style2=ocssRules1[1];
            console.log(style2);
            console.log(style2.style.display);

            $.ajax({
                url: jsctx + "/tenantReceive/tenantReceiveIsRead",
                type: "get",
                // data: {
                //     'tenantNoticeId': tenantNoticeId
                // },
                success: function (data) {
                    // layer.close(index);
                    if (data.status == 200) {
                        // data.data = '...'
                        // layer.msg("删除成功");
                        // reLoad();
                        // console.log('1');
                        console.log(data.data);
                        if(data.data != '0'&&data.data != null)
                        {
                            // console.log($('.pic_num').attr("aaa"))
                            if(data.data >9)
                            {
                                data.data = "...";
                            }
                            $(window.parent.document.getElementsByClassName("pic_num")).css("display","block").text(data.data);
                        }
                        else
                        {
                            $(window.parent.document.getElementsByClassName("pic_num")).css("display","none");
                        }
                    } else {
                        layer.msg(data.message);
                    }
                }
            });

        },0);

        //试加载

        <%--$('.title').append("<b>"+"${tenantReceive.title}"+"</b>");--%>

        <%--if('${tenantReceive.status}' == '1'){--%>
        <%--    $('.status').append("已读");--%>
        <%--}--%>
        <%--else{--%>
        <%--    $('.status').append("未读");--%>
        <%--}--%>
        <%--&lt;%&ndash;$('.content').append("${tenantReceive.content}");&ndash;%&gt;--%>
        if('${tenantReceive.showPlaceType}' == '1'){
            $('.pic').attr("src","${ctx}/statics/img/star2.png");
        }
        // else{
        //     $('.pic').attr("src","");
        // }
        <%--console.log('${tenantReceive.fileName1}');--%>
        if('${tenantReceive.fileName1}' == ''&&'${tenantReceive.fileName2}' == ''&&'${tenantReceive.fileName3}' == ''){
            $('.enclosure').css("display",'none');
            // $('.file1').css("display",'none');
            // $('.file2').css("display",'none');
            // $('.file3').css("display",'none');
        }
        if('${tenantReceive.fileName1}' == ''){
            $('.file1').css("display",'none');
        }
        if('${tenantReceive.fileName2}' == ''){
            $('.file2').css("display",'none');
        }
        if('${tenantReceive.fileName3}' == ''){
            $('.file3').css("display",'none');
        }
        if('${tenantReceive.fileName1}' != ''){
            $('.file1').append("<div id='littlely' class='col-md-12'><img src='${ctx}/statics/img/notice1.png'>" +
                "<span id ='litty' name='fileName1'>${tenantReceive.fileName1}</span>" +
                "<button class='loaded' onclick='load1()'>下载</button></div>");
        }
        if('${tenantReceive.fileName2}' != ''){
            $('.file1').append("<div id='littlely' class='col-md-12'><img src='${ctx}/statics/img/notice1.png'>" +
                "<span id ='litty' name='fileName2'>${tenantReceive.fileName2}</span>" +
                "<button class='loaded' onclick='load2()'>下载</button></div>");
        }
        if('${tenantReceive.fileName3}' != ''){
            $('.file1').append("<div id='littlely' class='col-md-12'><img src='${ctx}/statics/img/notice1.png'>" +
                "<span id ='litty' name='fileName3'>${tenantReceive.fileName3}</span>" +
                "<button class='loaded' onclick='load3()'>下载</button></div>");

        }


    });
    <%--const d = new Date("${tenantReceive.createdTime}");--%>
    <%--const resDate = d.getFullYear() + '-' + this.p((d.getMonth() + 1)) + '-' + this.p(d.getDate());--%>
    <%--const resTime = this.p(d.getHours()) + ':' + this.p(d.getMinutes()) + ':' + this.p(d.getSeconds());--%>
    <%--$('.time').append("<b>"+resDate+' '+resTime+"</b>");--%>
    <%--function p(s) {--%>
    <%--    return s < 10 ? '0' + s : s;--%>
    <%--};--%>
    window.onload = function () {
        const d = new Date("${tenantReceive.createdTime}");
        const resDate = d.getFullYear() + '-' + this.p((d.getMonth() + 1)) + '-' + this.p(d.getDate());
        const resTime = this.p(d.getHours()) + ':' + this.p(d.getMinutes()) + ':' + this.p(d.getSeconds());
        $('.time').append("<b>"+resDate+' '+resTime+"</b>");

    };
    function p(s) {
        return s < 10 ? '0' + s : s;
    };
    function reLoad() {
        // $('#exampleTable').bootstrapTable('refresh');
       // location.reload();
        if(window.name!="bencalie"){
            location.reload();
            window.name = "bencalie";
        } else {
            window.name = "";
        }
    }





  function load1(){
          var file = '${tenantReceive.contentFile1}';
          var fileName1 = '${tenantReceive.fileName1}';

      $.fileDownload(
          jsctx + "/tenantReceive/tenantReceiveDownLoad", { // 后台请求链接
              httpMethod: "GET",　　　　　　　　// 请求方式
              contentType: 'application/json',　 // 请求头
              data: {
                  'file':file,
                  'fileName':fileName1
              },
              prepareCallback: function (url) {
                  layer.msg("文件下载中...", {time: -1})
              },
              abortCallback: function (url) {
                  // 异常终止
                  layer.msg("文件下载异常！！");
              },
              successCallback: function (url) {
                  layer.msg("文件下载成功！！", {time: 1500});
              },
              failCallback: function (data) {
                  var str = "{" + data.substring(data.indexOf("{") + 1, data.indexOf("}")) + "}";
                  // layer.msg(JSON.parse(str).message);
              }
          })


  }
    function load2(){
        var file = '${tenantReceive.contentFile2}';
        var fileName1 = '${tenantReceive.fileName2}';

        $.fileDownload(
            jsctx + "/tenantReceive/tenantReceiveDownLoad", { // 后台请求链接
                httpMethod: "GET",　　　　　　　　// 请求方式
                contentType: 'application/json',　 // 请求头
                data: {
                    'file':file,
                    'fileName':fileName1
                },
                prepareCallback: function (url) {
                    layer.msg("文件下载中...", {time: -1})
                },
                abortCallback: function (url) {
                    // 异常终止
                    layer.msg("文件下载异常！！");
                },
                successCallback: function (url) {
                    layer.msg("文件下载成功！！", {time: 1500});
                },
                failCallback: function (data) {
                    var str = "{" + data.substring(data.indexOf("{") + 1, data.indexOf("}")) + "}";
                    // layer.msg(JSON.parse(str).message);
                }
            })


    }
    function load3(){
        var file = '${tenantReceive.contentFile3}';
        var fileName1 = '${tenantReceive.fileName3}';

        $.fileDownload(
            jsctx + "/tenantReceive/tenantReceiveDownLoad", { // 后台请求链接
                httpMethod: "GET",　　　　　　　　// 请求方式
                contentType: 'application/json',　 // 请求头
                data: {
                    'file':file,
                    'fileName':fileName1
                },
                prepareCallback: function (url) {
                    layer.msg("文件下载中...", {time: -1})
                },
                abortCallback: function (url) {
                    // 异常终止
                    layer.msg("文件下载异常！！");
                },
                successCallback: function (url) {
                    layer.msg("文件下载成功！！", {time: 1500});
                },
                failCallback: function (data) {
                    var str = "{" + data.substring(data.indexOf("{") + 1, data.indexOf("}")) + "}";
                    // layer.msg(JSON.parse(str).message);
                }
            })


    }
</script>
</body>
</html>
